package com.summer.wxapp.controller;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.context.annotation.Scope;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Component;

import com.summer.core.annotations.ScopeType;
import com.summer.core.util.FacesUtil;
/**
 * 微信小程序入口
 * @author Administrator
 *
 */
@Component
@Scope(ScopeType.REQUEST)
public class WechatAppHome {

	@Resource
	HibernateTemplate ht;
	
	public void getUserInfo() {
		HttpServletRequest request = FacesUtil.getHttpServletRequest();
		try {
			request.setCharacterEncoding("UTF-8");
			@SuppressWarnings("unchecked")
			Map<String, String[]> parameter = request.getParameterMap();// <String,String[]>
			String[] weUserId = parameter.get("weUserId");
			System.out.println(weUserId[0]);
			
			
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	
	private void responseMsg(String msg){
		HttpServletResponse response = FacesUtil.getHttpServletResponse();
		response.setCharacterEncoding("UTF8");
		response.setHeader("content-type", "text/html;charset=UTF-8");
		try {
			response.getWriter().write(msg);
			System.out.println(msg);
//			log.info(msg);
			FacesUtil.getCurrentInstance().responseComplete();
		} catch (IOException e1) {
			e1.printStackTrace();
		}
	}
}
